<template>
    <h2>我是About的内容</h2>
</template>

<script>
    export default {
        name: "About",
        mounted() {
            console.log('About 组件被挂载');
            window.aboutRoute = this.$route;
            window.aboutRouter = this.$router;
        },
        beforeDestroy() {
            console.log('About 组件被销毁');
        },
        // 组件内路由守卫，通过路由规则，进入该组件时被调用
        beforeRouteEnter(to, from, next) {
            console.log('About--beforeRouteEnter', to, from);
            // 判断是否需要鉴权
            if (to.meta.isAuth) {
                if (localStorage.getItem('school') === 'atguigu') {
                    next();
                } else {
                    alert('学校名称不对，无权限查看！');
                }
            } else {
                next();
            }
        },
        // 组件内路由规则，通过路由规则，离开该组件时被调用
        beforeRouteLeave(to, from, next) {
            console.log('About--beforeRouteLeave', to, from);
            next();
        }
    }
</script>

<style scoped>

</style>